<#assign className = table.className>
<#assign classNameLower = className?uncap_first>
<#assign classNameAllLower = className?lower_case>
package ${basePackage}.${moduleName}.model.entity;

import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
<#if table.enumColumns?? && (table.enumColumns?size>0)>
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.enums.IEnum;
</#if>
import ${basePackage}.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
<#list table.columns as column>
    <#if column.sqlTypeName == "DECIMAL">
import java.math.BigDecimal;
        <#break>
    </#if>
</#list>
<#list table.columns as column>
    <#if column.sqlName != 'create_time' && column.sqlName != 'update_time' && column.isDateTimeColumn>
import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
        <#break>
    </#if>
</#list>
<#list table.columns as column>
    <#if column.isNull?? && !column.isNull>
import javax.validation.constraints.NotNull;
        <#break>
    </#if>
</#list>
<#if adminSearchField?? && adminSearchField != "">
    <#list adminSearchField?split(",") as field>
        <#if field?contains("_") && field?contains(".")>
            <#if ancestorTableList?? && (ancestorTableList?size>0)>
                <#list ancestorTableList as ancestorTable>
                    <#if adminSearchField?? && adminSearchField != "">
                        <#if field?contains(ancestorTable.sqlName)>
import com.baomidou.mybatisplus.annotation.TableField;
                            <#list ancestorTable.columns as ancestorColumn>
                                <#if ancestorColumn.sqlName == field?substring(field?index_of(".")+1, field?length)>
                                    <#if ancestorColumn.isEnum>
import com.baomidou.mybatisplus.annotation.TableField;
import ${basePackage}.${moduleName}.model.entity.${ancestorTable.className};
                                    </#if>
                                    <#break>
                                </#if>
                            </#list>
                        </#if>
                    </#if>
                </#list>
            </#if>
            <#if parentTableList?? && (parentTableList?size>0)>
                <#list parentTableList as parentTable>
                    <#if adminSearchField?? && adminSearchField != "">
                        <#if field?contains(parentTable.sqlName)>
import com.baomidou.mybatisplus.annotation.TableField;
                            <#list parentTable.columns as parentColumn>
                                <#if parentColumn.sqlName == field?substring(field?index_of(".")+1, field?length)>
                                    <#if parentColumn.isEnum>
import com.baomidou.mybatisplus.annotation.TableField;
import ${basePackage}.${moduleName}.model.entity.${parentTable.className};
                                    </#if>
                                    <#break>
                                </#if>
                            </#list>
                        </#if>
                    </#if>
                </#list>
            </#if>
        </#if>
    </#list>
</#if>

/**
 * ${table.remarks}
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("${table.sqlName}")
public class ${className} extends BaseEntity<${className}> implements Serializable {

    private static final long serialVersionUID = 1L;

<#if table.enumColumns?? && (table.enumColumns?size>0)>
    <#list table.enumColumns as column>
    public enum ${column.columnName} implements IEnum<Integer> {

        <#list column.enumList as enum>
        /**
        * ${enum.desc}
        */
        ${enum.alias}(${enum.key},"${enum.desc}")<#if enum_has_next>,<#else>;</#if>
        </#list>

        private int code;
        private String desc;

        ${column.columnName}(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    </#list>
</#if>
<#list table.columns as column>
    <#if column.pk || column.sqlName == 'version' || column.sqlName == 'create_time' || column.sqlName == 'update_time' || column.sqlName == 'is_deleted' || column.sqlName == 'remark'>
    <#elseif column.isEnum && table.enumColumns?? && (table.enumColumns?size>0)>
        <#list table.enumColumns as enumColumn>
            <#if enumColumn.columnName == column.columnName>
    /**
     * ${column.columnAlias}
     */
    <#if column.isNull?? && !column.isNull>
    @NotNull
    </#if>
    private ${column.columnName} ${column.columnNameLower};

    /**
    * ${column.columnAlias}描述
    */
    @TableField(exist = false)
    private String ${column.columnNameLower}Desc;

    public String get${column.columnName}Desc() {
        return ${column.columnNameLower} == null ? null : ${column.columnNameLower}.getDesc();
    }

            </#if>
        </#list>
    <#elseif column.isImage>
    /**
     * ${column.columnAlias?substring(0, column.columnAlias?index_of(":"))}
     */
    <#if column.isNull?? && !column.isNull>
    @NotNull
    </#if>
    private ${column.simpleJavaType} ${column.columnNameLower};

    <#elseif column.isDateTimeColumn>
    /**
    * ${column.columnAlias}
    */
    <#if column.isNull?? && !column.isNull>
    @NotNull
    </#if>
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private ${column.simpleJavaType} ${column.columnNameLower};

    <#else>
    /**
     * ${column.columnAlias}
     */
    <#if column.isNull?? && !column.isNull>
    @NotNull
    </#if>
    private ${column.simpleJavaType} ${column.columnNameLower};

    </#if>
</#list>
<#if ancestorTableList?? && (ancestorTableList?size>0)>
    <#list ancestorTableList as ancestorTable>
        <#if adminSearchField?? && adminSearchField != "">
            <#list adminSearchField?split(",") as field>
                <#if field?contains(ancestorTable.sqlName)>
                    <#list ancestorTable.columns as ancestorColumn>
                        <#if ancestorColumn.sqlName == field?substring(field?index_of(".")+1, field?length)>
                            <#if ancestorColumn.isEnum>
    /**
     * ${ancestorTable.remarks}${ancestorColumn.columnAlias}
     */
    <#if ancestorColumn.isNull?? && !ancestorColumn.isNull>
    @NotNull
    </#if>
    @TableField(exist = false)
    private ${ancestorTable.className}.${ancestorColumn.columnName} ${ancestorTable.className?uncap_first}${ancestorColumn.columnName};

    /**
    * ${ancestorTable.remarks}${ancestorColumn.columnAlias}描述
    */
    @TableField(exist = false)
    private String ${ancestorTable.className?uncap_first}${ancestorColumn.columnName}Desc;

    public String get${ancestorTable.className}.${ancestorColumn.columnName}Desc() {
    return ${ancestorTable.className?uncap_first}${ancestorColumn.columnName} == null ? null : ${ancestorTable.className?uncap_first}${ancestorColumn.columnName}.getDesc();
    }

                            <#else>
    /**
     * ${ancestorTable.remarks}${ancestorColumn.columnAlias}
     */
    <#if ancestorColumn.isNull?? && !ancestorColumn.isNull>
    @NotNull
    </#if>
    @TableField(exist = false)
    private ${ancestorColumn.simpleJavaType} ${ancestorTable.className?uncap_first}${ancestorColumn.columnName};

                            </#if>
                            <#break>
                        </#if>
                    </#list>
                </#if>
            </#list>
        </#if>
    </#list>
</#if>
<#if parentTableList?? && (parentTableList?size>0)>
    <#list parentTableList as parentTable>
        <#if adminSearchField?? && adminSearchField != "">
            <#list adminSearchField?split(",") as field>
                <#if field?contains(parentTable.sqlName)>
                    <#list parentTable.columns as parentColumn>
                        <#if parentColumn.sqlName == field?substring(field?index_of(".")+1, field?length)>
                            <#if parentColumn.isEnum>
    /**
     * ${parentTable.remarks}${parentColumn.columnAlias}
     */
    <#if parentColumn.isNull?? && !parentColumn.isNull>
    @NotNull
    </#if>
    @TableField(exist = false)
    private ${parentTable.className}.${parentColumn.columnName} ${parentTable.className?uncap_first}${parentColumn.columnName};

    /**
    * ${parentTable.remarks}${parentColumn.columnAlias}描述
    */
    @TableField(exist = false)
    private String ${parentTable.className?uncap_first}${parentColumn.columnName}Desc;

    public String get${parentTable.className}.${parentColumn.columnName}Desc() {
        return ${parentTable.className?uncap_first}${parentColumn.columnName} == null ? null : ${parentTable.className?uncap_first}${parentColumn.columnName}.getDesc();
    }

                            <#else>
    /**
     * ${parentTable.remarks}${parentColumn.columnAlias}
     */
    <#if parentColumn.isNull?? && parentColumn.isNull>
    @NotNull
    </#if>
    @TableField(exist = false)
    private ${parentColumn.simpleJavaType} ${parentTable.className?uncap_first}${parentColumn.columnName};

                            </#if>
                            <#break>
                        </#if>
                    </#list>
                </#if>
            </#list>
        </#if>
    </#list>
</#if>
}
